package com.erp.stock.controller;

import com.erp.common.ResponseMessage;
import com.erp.common.controller.BaseControllerPowerful;
import com.erp.common.service.BaseService;
import com.erp.produce.service.FinishedGoodsInventoryService;
import com.erp.stock.entity.FinishedGoodsInventory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api("成品出入库管理")
@RestController
@RequestMapping("/finishedGoodsInven")
public class FinishedGoodsInventoryController extends BaseControllerPowerful<FinishedGoodsInventory> {
    @Autowired
    FinishedGoodsInventoryService service;

    @ApiOperation("成品出库，包含改变订单状态等操作")
    @PostMapping("/success")
    public ResponseMessage saveOrderStatus(Long orderId){
        Boolean success = service.finishedGoodsOutOfStock(orderId);
        if (success) {
            return ResponseMessage.ok();
        }
        return ResponseMessage.fail("成品出库失败，请重试");
    }

    @Override
    protected BaseService getService() {
        return this.service;
    }
}
